﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="Demo.Demos.Poll.Poll" MasterPageFile="~/Example.Master" %>

<asp:Content ID="Content4" runat="server" ContentPlaceHolderID="MainContent">
    <asp:UpdatePanel runat="server" ChildrenAsTriggers="true">
        <ContentTemplate>
            <d:EditPollDataContext runat="server" ID="ctrl_DataContext">
            <p>
                <i>Current model size is <b>
                    <%# ModelSize %></b>. View state containing view model is stored on
                    <asp:DropDownList runat="server" ID="ctrl_DropDownList" AutoPostBack="true" OnSelectedIndexChanged="Changed_ViewStateMode">
                        <asp:ListItem runat="server" Text="Client Browser" Value="Client" />
                        <asp:ListItem runat="server" Text="Server" Value="Server" />
                        <asp:ListItem runat="server" Text="Server (compressed)" Value="ServerCompressed" />
                    </asp:DropDownList>
                    .
                    </i></p><p><i>When you choose to store model together with view state on client, it behaves like any other ASP.NET application. View state is stored in hidden html field named __VIEWSTATE.
                    The problem is that this data is being sent with each request and for large view models and small bandwith clients that could cause problems. Another option is to store the view state and view model in database or even and even compress the data before storing it in database.
                    </i></p>
                    <p><i>
                        You can try multiple settings for yourself and notice how they affect the behaviour of the application.
                        </i>
                    </p>
                    <hr />
                <div class="form-horizontal">
                    <fieldset>
                        <div class="control-group">
                            <label class="control-label" for="focusedInput">
                                Title</label>
                            <div class="controls">
                                <cwfj:simpleeditor runat="server" datapath="Title" canbenull="false" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="focusedInput">
                                Question</label>
                            <div class="controls">
                                <cwfj:simpleeditor runat="server" datapath="Question" canbenull="false" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="focusedInput">
                                Publish date</label>
                            <div class="controls">
                                <cwfj:simpleeditor runat="server" datapath="PublishDate" showdate="true" showtime="true" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="focusedInput">
                                Summary text</label>
                            <div class="controls">
                                <cwfj:simpleeditor textmode="Multiline" height="100" id="FckEditor1" runat="server"
                                    datapath="SummaryText" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="focusedinput">
                                Can anonymous vote</label>
                            <div class="controls">
                                <cwfj:simpleeditor runat="server" datapath="CanAnonymousVote" showdate="true" showtime="true" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="focusedinput">
                                Poll languages</label>
                            <div class="controls">
                                <table class="table table-bordered table-striped">
                                    <tr>
                                        <th>
                                        </th>
                                        <th>
                                            Culture name
                                        </th>
                                        <th>
                                        </th>
                                        <cwf:CollectionEditor runat="server" DataPath="Cultures">
                                            <ItemTemplate>
                                                <tr>
                                                    <td>
                                                        <%# Container.DataItemIndex + 1 %>
                                                    </td>
                                                    <td>
                                                        <cwf:ModelValue runat="server" DataPath="CultureName" />
                                                    </td>
                                                    <td>
                                                        <asp:Button runat="server" Text="Remove" CssClass="btn btn-mini" CommandName="Remove" />
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                        </cwf:CollectionEditor>
                                    </tr>
                                </table>
                                Add new language
                                <cwfj:listeditor runat="server" datapath="AddCultureDropdown" autopostback="true"
                                    canbenull="True" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="focusedinput">
                                Answers</label>
                            <div class="controls">
                                <cwf:CollectionEditor runat="server" DataPath="Answers">
                                    <ItemTemplate>
                                        <div>
                                            <cwfj:listeditor runat="server" datapath="Order" autopostback="true" width="50px" />
                                            <asp:LinkButton ID="LinkButton1" runat="server" OnClick="RemoveAnswer_Click" Text="Remove"
                                                Style="float: right;" CssClass="btn btn-mini" />
                                            <d:PopupOpenerLink runat="server" OnGetViewModel="Popup_GetData" Text="Edit choices by language"
                                                Width="400" Height="300" FetchFromParent="true" OnViewModelChanged="Popup_ReturnedData"
                                                Url="AnswerByCulture.aspx" />
                                            <div class="poll-answers">
                                                <cwf:CollectionEditor runat="server" DataPath="AnswersByCulture">
                                                    <ItemTemplate>
                                                        <div>
                                                            <strong>
                                                                <cwf:ModelValue runat="server" DataPath="CultureName" />
                                                            </strong>
                                                            <cwf:IfElsePanel runat="server" ConditionDataPath="HasValue">
                                                                <IfTemplate>
                                                                    <cwf:ModelValue ID="ModelValue1" runat="server" DataPath="Answer" />
                                                                </IfTemplate>
                                                                <ElseTemplate>
                                                                    <i>&lt;Empty&gt;</i>
                                                                </ElseTemplate>
                                                            </cwf:IfElsePanel>
                                                        </div>
                                                    </ItemTemplate>
                                                </cwf:CollectionEditor>
                                            </div>
                                            <cwfj:validatorcontrol runat="server" onvalidaterules="Validate_Answer" />
                                        </div>
                                    </ItemTemplate>
                                </cwf:CollectionEditor>
                                <asp:Button ID="Button2" runat="server" OnClick="AddAnswer_Click" Text="Add answer"
                                    CssClass="btn btn-mini" />
                                <cwfj:validatorcontrol runat="server" onvalidaterules="Validate_Answers" />
                            </div>
                        </div>
                    </fieldset>
                </div>
                <div class="form-actions">
                    <asp:Button ID="Button1" runat="server" OnClick="Save_Click" Text="Save" CssClass="btn btn-primary" />
                </div>
            </d:EditPollDataContext>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
